<?php

class Cms_Decorator_FormElementsErrors extends Zend_Form_Decorator_Abstract

      {

     /**
     * Default placement: append
     * @var string
     */
    protected $_placement = 'APPEND';

  public function render($content)
    {
        $placement = $this->getPlacement();

        $element  = $this->getElement();

         $messages = $element->getMessages();

         $errors = '';
         
              if (!empty($messages)) {
                 if (is_array($messages)) {
                     foreach ($messages as $message) {
                         $errors = '<span class="error">' .$message. '</span>';
                     }
              	}else {
                    $errors = '<span class="error">' .$messages. '</span>';
                    }
              }

         $output = $errors;

        switch($placement)
        {
            case 'PREPEND':
                return $output . $content;
                break;
            case 'APPEND':
                return $content . $output;
                break;
            default:
                return $output . $content;
                break;
        }
    }



      }